<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表单事件</title>
    <script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#username").focus(function () {
                //改变当前元素的背景色
                $(this).css("background-color","yellow");
            });
            $("#password").blur(function () {
                $(this).css("background-color","red")
            });
        })
    </script>
</head>
<body>
     <form action="">
         用户名：<input type="text" id="username"/><br/>
         密码： <input type="password" id="password"/><br/>
               <input type="submit" value="显示">
     </form>
</body>
</html>